function confirmDelete(delUrl)
{
    if (confirm('Bạn có muốn xóa thật không?')==true) 
    {
            document.location = delUrl;
    }
}
function get_alias(){
    var str = (document.getElementById("idtitle").value);
    str= str.toLowerCase();
    str= str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g,"a");
    str= str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g,"e");
    str= str.replace(/ì|í|ị|ỉ|ĩ/g,"i");
    str= str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g,"o");
    str= str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g,"u");
    str= str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g,"y");
    str= str.replace(/đ/g,"d");
    str= str.replace(/!|@|\$|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\'| |\"|\&|\#|\[|\]|~/g,"-");
    str= str.replace(/-+-/g,"-"); //thay thế 2- thành 1-
    str= str.replace(/^\-+|\-+$/g,"");//cắt bỏ ký tự - ở đầu và cuối chuỗi
    document.getElementById("idalias").value = str;
    return str;
}
function BrowseServer()
{
    var finder = new CKFinder();
    finder.basePath = 'ckfinder/';	// The path for the installation of CKFinder (default = "/ckfinder/").
    finder.selectActionFunction = SetFileField;
	finder.popup();
}

function SetFileField( fileUrl )
{
    document.getElementById( 'xFilePath' ).value = fileUrl;
	var img = '<img src="/admin/timthumb.php?src='+fileUrl+'&amp;h=100&amp;w=100&amp;zc=1" />';
	document.getElementById( 'images_chose' ).innerHTML = img;
}

function BrowseServerFF()
{
    var finder = new CKFinder();
    finder.basePath = 'ckfinder/';	// The path for the installation of CKFinder (default = "/ckfinder/").
    finder.selectActionFunction = function (file) {
        document.getElementById( 'xFileFirstImage' ).value = file;
        var img = '<img src="/admin/timthumb.php?src='+file+'&amp;h=100&amp;w=100&amp;zc=1" />';
        document.getElementById( 'images_chose_ff' ).innerHTML = img;
    };
    finder.popup();
}

function BrowseServerMore(render_id)
{
    var finder = new CKFinder();
    finder.basePath = 'ckfinder/';	// The path for the installation of CKFinder (default = "/ckfinder/").
	finder.selectActionFunction = function( fileUrl ) {		
		$('#'+render_id).val(fileUrl);
		var img = '<img src="/admin/timthumb.php?src='+fileUrl+'&amp;h=100&amp;w=100&amp;zc=1" />';
		$('#images_chose_'+render_id).html(img);
	}
    finder.popup();
}

$(document).ready(function(){
    $('#checkall:checkbox').change(function () {
        if($(this).attr("checked")) $('input:checkbox').attr('checked','checked');
        else $('input:checkbox').removeAttr('checked');
    });
})